namespace Mytodotodaylist.Core.Schedule
{
    using System;
    using System.Collections.Generic;
    using Events;

    public class EventOcurrenceEvaluationFilter 
    {
        private List<Event> Events;

        public EventOcurrenceEvaluationFilter()
        {
        }

        public List<Event> Applay(List<Event> events)
        {
            var result = new List<Event>();

            var timeForEv = DateTime.Now;

            events.ForEach(x=>
                               {
                                   if(AreEqualTwoDatesWithoutMilisecondsCriteria(x.Date, timeForEv))
                                       result.Add(x);
                               });

            return result;
        }

        private bool AreEqualTwoDatesWithoutMilisecondsCriteria(DateTime d1, DateTime d2)
        {
            return
                (d1.Year == d2.Year) &&
                (d1.Month == d2.Month) &&
                (d1.Day == d2.Day) &&
                (d1.Hour == d2.Hour) &&
                (d1.Minute == d2.Minute) &&
                (d1.Second == d2.Second);
        }
    }
}